﻿namespace ReAnimation.Helpers.Common
{
    public class ValidationResult<T>
    {
        public bool IsError { get; set; }
        public T Error { get; set; }

        public ValidationResult(bool isError, T error)
        {
            IsError = isError;
            Error = error;
        }

        public static ValidationResult<T> SuccessValidation()
        {
            return new ValidationResult<T>(false,default(T));
        }

        public static ValidationResult<T> FailValidation(T error)
        {
            return new ValidationResult<T>(true,error);
        }

        public static implicit operator bool(ValidationResult<T> validationResult)
        {
            return !validationResult.IsError;
        }
    }
}
